package com.hangxin.word.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hangxin.word.domain.VocabMgrWord;
import com.hangxin.word.mapper.VocabMgrWordMapper;
import com.hangxin.word.service.IVocabMgrWordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 词库管理 Impl
 *
 * @author ZX
 */
@Service
public class VocabMgrWordImpl extends ServiceImpl<VocabMgrWordMapper, VocabMgrWord> implements IVocabMgrWordService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean confirmProfessional(List<Long> ids) {
        LambdaUpdateWrapper<VocabMgrWord> wrapper = new LambdaUpdateWrapper<>();
        wrapper.in(VocabMgrWord::getId, ids)
                .eq(VocabMgrWord::getType, 0)   // 新词
                .eq(VocabMgrWord::getStatus, 0) // 待确认
                .set(VocabMgrWord::getType, 1)  // 专业词
                .set(VocabMgrWord::getStatus, 1); // 已确认
        return update(wrapper);
    }
}
